library(RSQLite)

inhalt <- readLines("C:/R/Bestellungen.txt")

db <- dbConnect(RSQLite::SQLite(), "C:/R/Auswertung.sqlite")


i <- 0
repeat  {
 
  #Datum extrahieren
  i <- i + 1
  teile <- strsplit(inhalt[i],":") 
  datum <- teile[[1]][2]
  
  i <- i + 1
  teile <- strsplit(inhalt[i],"=") 
  id <- teile[[1]][2]
  
  i <- i + 1
  teile <- strsplit(inhalt[i],"=") 
  artikel <- teile[[1]][2]
  
  i <- i + 1
  teile <- strsplit(inhalt[i],"=") 
  anzahl <- teile[[1]][2]
  
  
  i <- i + 1
  teile <- strsplit(inhalt[i],"=") 
  kunden_id <- teile[[1]][2]
  
  sqlstring <- paste0("INSERT INTO Bestellungen VALUES (", id , ",'", artikel , "',", kunden_id, "," , anzahl , ",'", datum, "');")
  dbExecute(db, sqlstring)  
  
  i <- i + 1
  
  if (i > length(inhalt)) break
  
}

library(RSQLite)

db <- dbConnect(RSQLite::SQLite(), "C:/R/Auswertung.sqlite")



ergebnis <- dbGetQuery(db, 'SELECT * FROM Bestellungen')

print (ergebnis)


dbDisconnect(db)
